home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1350 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  45 lines

  1. Path: news.onramp.net!usenet
  2. From: dekorte@suite.com (Steve Dekorte)
  3. Newsgroups: comp.lang.c,comp.lang.objective-c
  4. Subject: Re: Comma Delimited function wanted
  5. Date: 13 Jan 1996 02:44:57 GMT
  6. Organization: On-Ramp; Individual Internet Connections; Dallas/Ft Worth/Houston, TX USA
  7. Message-ID: <4d76b9$sk9@news.onramp.net>
  8. References: <4d3360$kg3@tahko.lpr.carel.fi>
  9. NNTP-Posting-Host: s172-10.suite.com
  10.  
  11. aril@cmt.lpr.mail.carel.fi (Ari Lukumies) writes:
  12. >Help with a comma delimited function needed.
  13.  
  14. In Objective-C, you might have use something like the following method in your String class;
  15.  
  16. - setList:aList toSelfDelimitedStringValue:(char *)astring
  17. {
  18.    char *p;
  19.    id newString = [[String alloc] init];
  20.          
  21.    if ( p = rindex ( [self stringValue], '\n')) { *p  = '\0'; }
  22.  
  23.    p = strtok((char *)[self stringValue], astring);
  24.    if (p) { [newString setStringValue:p];}
  25.    [aList addObject:newString];  
  26.  
  27.    while (p) 
  28.    {
  29.       p = strtok (NULL, astring);
  30.       if (p) 
  31.       { 
  32.     newString = [[String alloc] init];
  33.     [newString setStringValue:p]; 
  34.     [aList addObject:newString];            
  35.       }
  36.    }
  37.    return self;
  38. }
  39.  
  40. --
  41. Steve Dekorte 
  42. Objective-C/NEXTSTEP developer
  43. http://www.marble.com/~dekorte
  44. NeXTmail, MIME welcome. 
  45.